package com.lianzai.shop.controller;

import com.lianzai.common.controller.BaseController;
import com.lianzai.common.utils.PageUtils;
import com.lianzai.common.utils.Query;
import com.lianzai.shop.model.Use;
import com.lianzai.shop.service.UseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/shop/use")
public class UseController extends BaseController {

    @Autowired
    UseService useService;

    @GetMapping()
    String use(Model model){
        return "shop/use/list";
    }

    @ResponseBody
    @GetMapping("/list")
    public PageUtils list(@RequestParam Map<String, Object> params){
        Query query = new Query(params);
        List<Use> carInfoList = useService.list(query);
        int total = useService.count(query);
        PageUtils pageUtils = new PageUtils(carInfoList, total);
        return pageUtils;
    }

}
